home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d7 / lanperf.arc / LPTEST.ASM < prev    next >
Assembly Source File  |  1988-06-04  |  7KB  |  346 lines

  1.     TITLE   LPTEST ASM routines -- Version 1.00
  2.     NAME    LPTEST
  3.  
  4.     public    _lpstart
  5.     public    _rtest
  6.     public    _wtest
  7.  
  8. MAXBLK    = 8192        ; needs to match with MAXBLK in LANPERF.C
  9.  
  10. ;
  11. ; Values for DOS function calls (int 21h)
  12. ;
  13. CONIO    = 06h
  14. CONCHK    = 0Bh
  15. CREATE    = 3Ch
  16. OPEN    = 3Dh
  17.  O_RD    = 0
  18.  O_WR    = 1
  19.  O_RW    = 2
  20. CLOSE    = 3Eh
  21. READ    = 3Fh
  22. WRITE    = 40h
  23. DELETE    = 41h
  24. SEEK    = 42h
  25. CHMOD    = 43h
  26. MKTEMP    = 5Ah
  27.  
  28.  
  29. _DATA    SEGMENT word public 'DATA'
  30.  
  31. ;
  32. ;    Data shared with LANPERF.C, the main driver program
  33. ;
  34. extrn    _master:word    ; set if we started the test
  35. extrn    _blksize:word    ; block size (bytes)
  36. extrn    _ioshare:byte    ; file sharing mode
  37. extrn    _iobuf:byte    ; I/O buffer
  38. extrn    _duration:word    ; length of test (seconds)
  39. extrn    _ops:word    ; (long) number of operations performed
  40. extrn    _filesize:word    ; size of file (blksize blocks)
  41. extrn    _fname:byte    ; file name buffer
  42. ;
  43. ;    Local data
  44. ;
  45. endtime    dw    0,0    ; test ending time (ticks)
  46. n_blks    dw    0    ; number of blocks before re-seek
  47. iopos    dw    0    ; write position in _iobuf
  48.  
  49. _DATA    ENDS
  50.  
  51.  
  52. LOWMEM  segment at 0
  53.  
  54.     org     046Ch
  55. clock    dw    ?,?             ; BIOS clock value
  56.  
  57. LOWMEM  ends
  58.  
  59. ;
  60. ;    GTICKS - macro to load BIOS tick count
  61. ;        (assumes ES is set to LOWMEM)
  62. ;
  63. GTICKS    macro    LOREG,HIREG
  64.     cli
  65.     mov    LOREG,es:[clock]
  66.     mov    HIREG,es:[clock+2]
  67.     sti
  68.     endm
  69.  
  70. _TEXT    segment byte public 'CODE'
  71.  
  72. DGROUP    group    _DATA
  73.     assume    CS:_TEXT, DS:DGROUP, ES:LOWMEM
  74.  
  75. ;
  76. ;    lpmark - wait for key press or creation of start file
  77. ;
  78. ;    Return: 0 for "test has started"; DOS error code otherwise
  79. ;        Sets _master to 1 if we started the test, else 0
  80. ;
  81. _lpstart proc    near
  82.     mov    [_master],0    ; assume we didn't start
  83. retry:    mov    ah,CONCHK    ; check for a char a few times
  84.     int    21h
  85.     or    al,al
  86.     jnz    gotch
  87.     mov    ah,CONCHK
  88.     int    21h
  89.     or    al,al
  90.     jnz    gotch
  91.     mov    ah,CONCHK
  92.     int    21h
  93.     or    al,al
  94.     jnz    gotch
  95.     mov    ah,CHMOD    ; see if trigger file is there
  96.     mov    al,0
  97.     lea    dx,_fname
  98.     int    21h
  99.     jc    retry
  100.     jmp    short mkok
  101. gotch:    mov    dl,0FFh
  102.     mov    ah,CONIO    ; flush out the char we got
  103.     int    21h
  104.     mov    ah,CONIO    ; catch extended ascii chars
  105.     int    21h
  106.     mov    [_master],1    ; we started the test
  107.     mov    ah,CREATE    ; make the trigger file
  108.     xor    cx,cx
  109.     lea    dx,_fname
  110.     int    21h
  111.     jc    mkerr
  112.     mov    bx,ax
  113.     mov    ah,CLOSE
  114.     int    21h
  115.     jc    mkerr
  116. mkok:    xor    ax,ax        ; signal success
  117. mkerr:    ret
  118.  
  119. _lpstart endp
  120.  
  121.  
  122. ;
  123. ;  _rtest - LANPERF sequential read test
  124. ;
  125. ;  Creates a file of (_blksize * _filesize) bytes, then reads
  126. ;  it sequentially.  The file is rewound when EOF is reached.
  127. ;
  128. _rtest    proc    near
  129.     push    es
  130.     xor    ax,ax        ; point es to LOWMEM
  131.     mov    es,ax
  132.     mov    ah,MKTEMP    ; create temp file
  133.     xor    cx,cx        ;  normal attributes (read/write)
  134.     lea    bx,_fname    ;  address of file name buffer
  135.     mov    [bx],ch        ;  (must be null terminated)
  136.     mov    dx,bx
  137.     int    21h
  138.     jnc    rok
  139.     jmp    rnopen
  140. rok:    mov    bx,ax        ; put handle in bx
  141.     call    finit        ; fill file with data
  142.     jc    rerror
  143.     mov    ah,CLOSE    ; close the temp file
  144.     int    21h
  145.     jc    rerror
  146.     mov    ah,OPEN        ; re-open file with the
  147.     mov    al,[_ioshare]    ;    desired sharing mode
  148.     lea    dx,_fname
  149.     int    21h
  150.     jc    rerror
  151.     mov    bx,ax        ; put handle in bx
  152.     xor    ax,ax        ; zero out op count
  153.     mov    [_ops],ax    ;
  154.     mov    [_ops+2],ax    ;
  155.     mov    ax,[_filesize]    ; initialize block count
  156.     mov    [n_blks],ax    ;
  157.     push    bx        ; save handle
  158.     call    clkon        ; figure out ending time
  159.     pop    bx        ; put handle in bx for loop
  160. rloop:
  161.     mov    cx,[_blksize]    ; block size to be read
  162.     lea    dx,_iobuf    ; buffer address
  163.     mov    ah,READ        ; read a block
  164.     int    21h
  165.     jc    rerror
  166.     cmp    ax,cx        ; I/O not completed,
  167.     jne    rbadio        ;  real trouble is brewing
  168.     add    [_ops],1    ; rack up another operation
  169.     adc    [_ops+2],0    ;
  170.     dec    [n_blks]    ; need to re-start at BOF?
  171.     jnz    rnseek
  172.     mov    ah,SEEK        ; yes
  173.     xor    cx,cx
  174.     mov    al,cl
  175.     mov    dx,cx
  176.     int    21h
  177.     jc    rerror
  178.     mov    ax,[_filesize]    ; reset count
  179.     mov    [n_blks],ax
  180. rnseek:    GTICKS    ax,dx        ; get current time
  181.     sub    ax,[endtime]    ; subtract ending time
  182.     sbb    dx,[endtime+2]
  183.     jb    rloop        ; keep going until past endtime
  184.  
  185.     xor    ax,ax        ; zero means successful
  186.     jmp    rexit
  187.  
  188. rbadio:    mov    ax,-1        ; not all bytes read/written
  189. rerror:                ; errors have ax set to DOS err code
  190. rexit:    push    ax
  191.     mov    ah,CLOSE    ; close the file (bx has handle)
  192.     int    21h
  193.     mov    ah,DELETE    ; delete the file
  194.     lea    dx,_fname
  195.     int    21h
  196.     pop    ax
  197. rnopen:    pop    es
  198.     ret
  199.  
  200. _rtest    endp
  201.  
  202.  
  203. ;
  204. ;  _wtest - LANPERF sequential write test
  205. ;
  206. ;  Sequentially writes a file of (_blksize * _filesize) bytes.
  207. ;  The file is rewound when the desired file size is reached.
  208. ;  To defeat cacheing schemes that recognize and ignore repeated
  209. ;  writes of the same data, the data is changed on each write.
  210. ;
  211. _wtest    proc    near
  212.  
  213.     push    es
  214.     xor    ax,ax        ; point es to LOWMEM
  215.     mov    es,ax
  216.     mov    ah,MKTEMP    ; create temp file
  217.     xor    cx,cx        ;  normal attributes (read/write)
  218.     lea    bx,_fname    ;  address of file name buffer
  219.     mov    [bx],ch        ;  (must be null terminated)
  220.     mov    dx,bx
  221.     int    21h
  222.     jnc    wok
  223.     jmp    wnopen
  224. wok:    mov    bx,ax
  225.     mov    ah,CLOSE    ; close the file
  226.     int    21h
  227.     jnc    wner
  228.     jmp    werror
  229. wner:    mov    ah,OPEN        ; open file with
  230.     mov    al,[_ioshare]    ;  sharing mode from cmd line
  231.     or    al,O_RW        ; read/write access
  232.     lea    dx,_fname
  233.     int    21h
  234.     jc    werror
  235.     mov    bx,ax        ; handle in bx
  236.     xor    ax,ax        ; zero out op count
  237.     mov    [_ops],ax    ;
  238.     mov    [_ops+2],ax    ;
  239.     mov    ax,[_filesize]    ; initialize block count
  240.     mov    [n_blks],ax    ;
  241.     push    bx        ; save handle
  242.     call    clkon        ; figure out ending time
  243.     pop    bx        ; put handle in bx for loop
  244.     mov    [iopos],offset _iobuf-1
  245. wloop:
  246.     mov    dx,[iopos]    ; change position in _iobuf
  247.     inc    dx        ;   to vary the data pattern
  248.     cmp    dx,offset _iobuf+MAXBLK
  249.     jb    wrtblk
  250.     lea    dx,_iobuf
  251. wrtblk:    mov    [iopos],dx
  252.     mov    cx,[_blksize]    ; block size to be written
  253.     mov    ah,WRITE    ; perform write
  254.     int    21h
  255.     jc    werror
  256.     cmp    ax,cx        ; I/O not completed,
  257.     jne    wbadio        ;  real trouble is brewing
  258.     add    [_ops],1    ; rack up another operation
  259.     adc    [_ops+2],0    ;
  260.     dec    [n_blks]    ; need to re-start at BOF?
  261.     jnz    wnseek
  262.     mov    ah,SEEK        ; yes
  263.     xor    cx,cx
  264.     mov    al,cl
  265.     mov    dx,cx
  266.     int    21h
  267.     jc    werror
  268.     mov    ax,[_filesize]    ; reset count
  269.     mov    [n_blks],ax
  270. wnseek:    GTICKS    ax,dx        ; get current time
  271.     sub    ax,[endtime]    ; subtract ending time
  272.     sbb    dx,[endtime+2]
  273.     jb    wloop        ; keep going until past endtime
  274.  
  275.     xor    ax,ax        ; zero means successful
  276.     jmp    wexit
  277.  
  278. wbadio:    mov    ax,-2        ; not all bytes written
  279. werror:                ; errors have ax set to DOS err code
  280. wexit:    push    ax
  281.     mov    ah,CLOSE    ; close the file (bx has handle)
  282.     int    21h
  283.     mov    ah,DELETE    ; delete the file
  284.     lea    dx,_fname
  285.     int    21h
  286.     pop    ax
  287. wnopen:    pop    es
  288.     ret
  289.  
  290. _wtest    endp
  291.  
  292.  
  293. ;
  294. ;    finit - initialize file with data for reading
  295. ;
  296. finit    proc    near        ; bx has file handle
  297.  
  298.      mov    cx,[_blksize]
  299.     lea    dx,_iobuf
  300.     mov    ax,[_filesize]
  301.     mov    [n_blks],ax
  302. rbuild:
  303.     mov    ah,WRITE
  304.     int    21h
  305.     jc    ferror
  306.     dec    [n_blks]
  307.     jnz    rbuild
  308.  
  309.     mov    ah,SEEK        ; seek to beginning of file
  310.     xor    cx,cx
  311.     mov    al,cl
  312.     mov    dx,cx
  313.     int    21h
  314. ferror:    ret
  315.  
  316. finit    endp
  317.  
  318.  
  319. ;
  320. ;    clkon - calculate test endtime from duration
  321. ;
  322. ;    NOTE: This routine fails if midnight is crossed
  323. ;
  324. clkon    proc    near
  325.     mov    ax,[_duration]    ; get run time in seconds
  326.     xor    dx,dx        ; convert to ticks, .2 seconds first
  327.     mov    cx,5
  328.     div    cx
  329.     mov    bx,ax
  330.     mov    ax,[_duration]
  331.     mov    cx,18        ; now the 18 seconds part
  332.     mul    cx
  333.     add    ax,bx
  334.     adc    dx,0        ; duration (in ticks) now in ax:dx
  335.     mov    [endtime],ax
  336.     mov    [endtime+2],dx
  337.     GTICKS    ax,dx        ; get current time in ticks
  338.     add    [endtime],ax    ; add to duration
  339.     adc    [endtime+2],dx
  340.     ret
  341. clkon    endp
  342.  
  343. _TEXT   ENDS
  344.  
  345.         END 
  346.